<template>
	<view class="app">
		<!-- 头部 -->
		<view class="header">
			<view class="header-aut">
				<view class="header_left">
					<van-image width="100rpx" height="100rpx" :src="user.photo" round />
					<text>{{user.mobile}}</text>
				</view>
				<view class="header_right">
					<text>个人信息></text>
				</view>
			</view>
			<!-- 阅读时常 -->
			<view class="read">
				<view class="read_info">
					<van-image width="40rpx" height="40rpx" src="/static/书本.png" />
					今日阅读
					<text>10</text>
					分钟
				</view>
			</view>
		</view>
		<!--  -->
	</view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import {
		ref
	} from "vue";
	onLoad(() => {
		const token = uni.getStorageSync('token');
		const tokens = 'Bearer' + ' ' + token
		getuser(tokens)
	})
	const user = ref({});
	const getuser = async (token) => {
		let {
			data: {
				data
			},
			statusCode
		} = await uni.request({
			url: 'http://toutiao.itheima.net/v1_0/user/profile',
			method: "GET",
			header: {
				Authorization: token
			}
		})
		if (statusCode == 401) {
			uni.redirectTo({
				url: '/pages/Login/Login?user=1'
			})
		}
		user.value = data;
		console.log(user.value);
	}
</script>

<style lang="less">
	.header {
		height: 45vh;
		padding: 0 4vw;
		background: linear-gradient(318deg, #b2b5db 2%, #565482 85%, #494675 97%);
		border-bottom-left-radius: 10vw;
		border-bottom-right-radius: 10vw;
		color: #fff;

		.header-aut {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 25px 0 15px 0;

			.header_left {
				display: flex;
				align-items: center;

				text {
					margin-left: 12px;
					font-size: 19px;
					font-weight: 800;
				}
			}

			.header_right {
				font-size: 12px;
			}
		}

		.read_info {
			width: 39vw;
			display: flex;
			align-items: center;
			background: linear-gradient(319deg, #585089, #2c2a6b 98%);
			border-radius: 50rpx;
			padding: 5rpx 30rpx;
			text-align: center;
			font-size: 25rpx;

			van-image {
				margin-right: 16rpx;
				margin-top: 10rpx;
			}

			text {
				color: #ffbc3d;
				font-size: 40rpx;
				margin: 0 14rpx;
			}
		}
	}
</style>
